﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.ComponentModel.DataAnnotations;

namespace Upreader.Application.Model
{
    /// <summary>
    /// Represents a file segment by referring to an article on usenet
    /// </summary>
    public class Segment : ModelBase
    {
        #region Properties

        /// <summary>
        /// Get or set the index location of this segment indicating in what sequence a segment should be assembled in the file
        /// </summary>
        public int Index { get; set; }

        /// <summary>
        /// Get or set the length in bytes of this segment
        /// </summary>
        public int Length { get; set; }

        /// <summary>
        /// Get or set the ID of the article to fetch
        /// </summary>
        [Required(AllowEmptyStrings = false)]
        public string ArticleId { get; set; }

        /// <summary>
        /// Get or set the state of the segment
        /// </summary>
        [Required]
        public SegmentState State { get; set; }

        /// <summary>
        /// Get or set the name of the segment when cached
        /// </summary>
        [Required]
        public string CachedFileName { get; set; }

        /// <summary>
        /// Get or set the Id of the file this segment belongs to
        /// </summary>
        public int FileId { get; set; }

        /// <summary>
        /// Get or set whether the first byte in the buffer is expected to be yEnc escaped. 
        /// Who can tell me what the creator of yEnc was smoking when he specified this?
        /// </summary>
        public bool FirstByteIsYencEscaped { get; set; }

        #endregion // Properties
    }
}
